procedure findBridges();

var
	timer : longint;
	tin, fup : array[0..MAXN] of longint;
	used : array[0..MAXN] of boolean;

	procedure dfs(v, p : longint);

	var
		i, tt, tto : longint;
	
	begin
		used[v] := true;
		tin[v] := timer;
		fup[v] := timer;
		inc(timer);
		tt := length(g[v]) - 1;
		for i := 0 to tt do begin
			tto := g[v][i];
			if tto = p then continue;
			if used[tto] then fup[v] := min(fup[v], tin[tto]) else begin
				dfs(tto, v);
				fup[v] := min(fup[v], fup[tto]);
				if fup[tto] > tin[v] then begin
					inc(ans);
					a[ans][1] := v;
					a[ans][2] := tto;
				end;
			end;
		end;
	end;

begin
	ans := 0;
	timer := 0;
	fillchar(used, sizeof(used), 0);
	fillchar(tin, sizeof(tin), 0);
	fillchar(fup, sizeof(fup), 0);
	dfs(1, 0);
end;
